package com.shenmazong.servereduschool.controller;

import com.github.pagehelper.PageInfo;
import com.shenmazong.servereduschool.pojo.TbStaff;
import com.shenmazong.servereduschool.service.TbStaffService;
import com.shenmazong.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 职员
 * kxt
 */
@RestController
@RequestMapping("/stall")
public class TbStaffController {
    @Autowired
    TbStaffService tbStaffService;

    /**
     * 职员列表
     * @param pageNum
     * @param pageSize
     * @param tbStaff
     * @return
     */
    @PostMapping("/list/{pageNum}/{pageSize}")
    public ResultResponse findStaffList(@PathVariable("pageNum") Integer pageNum,
                                        @PathVariable("pageSize") Integer pageSize,
                                        @RequestBody TbStaff tbStaff){
        PageInfo pageInfo=tbStaffService.findStaffList(pageNum,pageSize,tbStaff);
        return ResultResponse.SUCCESS(pageInfo);
    }

    /**
     * 职员添加
     * @param tbStaff
     * @return
     */
    @PostMapping("/save")
    public ResultResponse save(@RequestBody TbStaff tbStaff){
        return tbStaffService.add(tbStaff);
    }

    /**
     * 职员回显
     * @param staffId
     * @return
     */
    @PostMapping("/queryByStaffId/{staffId}")
    public ResultResponse queryByStaffId(@PathVariable("staffId") Long staffId){
        return tbStaffService.queryByStaffId(staffId);
    }

    /**
     * 职员修改
     * @param tbStaff
     * @return
     */
    @PostMapping("/updateStaff")
    public ResultResponse updateStaff(@RequestBody TbStaff tbStaff){
        return tbStaffService.updateStaff(tbStaff);
    }

    /**
     * 职员删除
     * @param staffId
     * @return
     */
    @PostMapping("/delByStaffId/{staffId}")
    public ResultResponse delByStaffId(@PathVariable("staffId") Long staffId){
        return tbStaffService.delByStaffId(staffId);
    }

    @PostMapping("/delAll")
    public ResultResponse delAll(@RequestBody List<TbStaff> ids){
        return tbStaffService.delAll(ids);
    }


}
